package com.school;

import java.util.Scanner;

public class leanString2 {
    public static void main(String[] args) {
        String rightname="admin";
        String rpwd="123456";
        Scanner sc=new Scanner(System.in);
        for (int i=0;i<3;i++) {

            System.out.println("请输入用户名：");
            String name=sc.next();
            System.out.println("请输入密码：");
            String pwd=sc.next();

            int c=2-i;

            if(name==rightname&&pwd==rpwd){
                System.out.println("登录成功");
                break;
            }else{
                System.out.println("登录失败"+"还有"+c+"次机会");
            }
        }


    }


}
